<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="tag" tagdir="/WEB-INF/tags"%>
<html>
<head>
<tag:header />
</head>
<body id="main_layout">
	<div id="pageGrid"></div>
	<script type="text/template" id="pageGridTmpl">
    <form>
		    <!--标题-->
			<div class="col">
				<input id="title" data-qfield="title" class="query" data-qoperator="EQUAL" data-qtype="STRING"/>
			</div>

			<!--发送状态-->
			<div class="col">
				<select id="sendStatus" data-qfield="sendStatus" class="easyui-combobox query" data-options="editable:false" data-qoperator="EQUAL" data-qtype="STRING">
					<option value="">所有</option>
					<option value="0">未发送</option>
					<option value="1">已发送</option>
				</select>
			</div>

			<!--开始时间-->
        	<div class="col">
				<input id="startTime" data-qfield="startTime" class="easyui-datebox query" data-qoperator="GREATER" data-qtype="DATE"/>
			</div>

	        <!--结束时间-->
        	<div class="col">
				<input id="endTime" data-qfield="endTime" class="easyui-datebox query" data-qoperator="LESS" data-qtype="DATE"/>
			</div>

			<!--增加人-->
			<div class="col">
				<input id="addBy" data-qfield="addBy" class="query" data-qoperator="EQUAL" data-qtype="STRING"/>
			</div>

			<!--发起人-->
			<div class="col">
				<input id="sender" data-qfield="sender" class="query" data-qoperator="EQUAL" data-qtype="STRING"/>
			</div>	


				

    </form>
</script>
<script type="text/javascript">
	var pagegrid;
	(function() {
		//参数配置
		var options = {
			containerId : 'pageGrid',
			pageGridTmplId : 'pageGridTmpl',
			contextUrl : '${pageContext.request.contextPath}',
			module : '${module}',
			submodule : '${submodule}',
			moduleName : '问卷列表',
			useCommonApi: false,
			instantSearch : true
		};

		options.datagridOptions = {
            onDblClickRow: function (index, row) {
                $(this).datagrid('unselectAll');
                $(this).datagrid('selectRow', index);
                pagegrid.openView();
            }
		};
		
		/** 设置自定义按钮事件处理方法 **/
        options.btnHandlers = {

        };

		// grid加载成功后方法
        options.onPageLoadSuccess = function (res) {
            debugger;
            // body值
            $('body').data('pagegrid_data',res);

            var _rows = res.rows;

            // grid
           	var $datagrid_btable = $('.datagrid-view2 .datagrid-btable');

           	// 调查范围渲染 1 会员2 推荐人3 外勤人员
			var $cellScope = $datagrid_btable.find('.datagrid-cell-c1-SCOPENAME');
			$.each(_rows,function(_index,_object){
                var _scope = _object.SCOPE;
                var $cell = $($cellScope[_index]);

                var _arr = _scope.split(',');
				for (var i =0;i < _arr.length;i++){
				    var _s = _arr[i];

				    // 1会员 2推荐人 3外勤人员
				    if('1' == _s){
                        $cell.append('&nbsp;');
                        $cell.append('<a href="javascript:void(0);" class="hy_cls" >会员</a>');
                        $cell.append('&nbsp;');
                        $cell.find('.hy_cls').on('click',hy_clsFn);
					}

                    if('2' == _s){
                        $cell.append('&nbsp;');
                        $cell.append('<a href="javascript:void(0);" class="tjr_cls" >推荐人</a>');
                        $cell.append('&nbsp;');
                        $cell.find('.tjr_cls').on('click',tjr_clsFn);
                    }

                    if('3' == _s){
                        $cell.append('&nbsp;');
                        $cell.append('<a href="javascript:void(0);" class="wqry_cls" >外勤人员</a>');
                        $cell.append('&nbsp;');
                        $cell.find('.wqry_cls').on('click',wqry_clsFn);
                    }

				}

			});
            $cellScope.find('.hy_cls').each(function(_index,_object){
                $(_object).data('_index',_index);
            });
            $cellScope.find('.tjr_cls').each(function(_index,_object){
                $(_object).data('_index',_index);
            });
            $cellScope.find('.wqry_cls').each(function(_index,_object){
                $(_object).data('_index',_index);
            });


           	// 统计方法 渲染
           	var $lastCell = $datagrid_btable.find('.datagrid-cell-c1-STATISTICS');
            $lastCell.html('<a href="javascript:void(0);">统计</a>');
            $lastCell.find('a').each(function(_index,_object){
                $(_object).data('_index',_index);
			});
            $lastCell.find('a').on('click',statisticsFn);
        }
		//初始化
		pagegrid = new ehsure.PageGrid(options).build();


		
	})();
	
	//查看详细信息
    function viewDetail(id) {
    	pagegrid.openWin('detail', '', "id=" + id);
    }

    // 调查范围FN 1 会员2 推荐人3 外勤人员
	// 会员
    function hy_clsFn(){
        debugger;
        var _pagegrid_data = $('body').data('pagegrid_data');
        var _index = $(this).data('_index');
        var _rowNum = $(this).parents('.datagrid-view').find('.datagrid-cell-rownumber').eq(_index).html();
        var _row = _pagegrid_data.rows[_index];

    }
    // 推荐人
    function tjr_clsFn(){
        debugger;
        var _pagegrid_data = $('body').data('pagegrid_data');
        var _index = $(this).data('_index');
        var _rowNum = $(this).parents('.datagrid-view').find('.datagrid-cell-rownumber').eq(_index).html();
        var _row = _pagegrid_data.rows[_index];

    }
    // 外勤人员
    function wqry_clsFn(){
        debugger;
        var _pagegrid_data = $('body').data('pagegrid_data');
        var _index = $(this).data('_index');
        var _rowNum = $(this).parents('.datagrid-view').find('.datagrid-cell-rownumber').eq(_index).html();
        var _row = _pagegrid_data.rows[_index];

    }
    // 统计FN
    function statisticsFn(){
        debugger;
        var _pagegrid_data = $('body').data('pagegrid_data');
        var _index = $(this).data('_index');
        var _rowNum = $(this).parents('.datagrid-view').find('.datagrid-cell-rownumber').eq(_index).html();
        var _row = _pagegrid_data.rows[_index];

	}

</script>
</body>
</html>